﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Caipushezhi.aspx.cs" Inherits="Catering.Catering_Page.Caipin.Caipin_jcsz.Caipushezhi" %>

<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/Dtd/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>菜品管理</title>
<link rel="stylesheet" type="text/css" href="../../../../Style/head.css" />
<link rel="stylesheet" type="text/css" href="../../../../Style/center.css"/>
<link href="../../../../Style/StyleSheet.css" rel="stylesheet" type="text/css" />
<link href="../../../../Style/jquery.treeview.css" rel="stylesheet" type="text/css" />
<link href="../../../../Style/tinybox_style.css" rel="stylesheet" type="text/css" />
<link href="../../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
<script src="../../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="../../../Scripts/jquery.js" type="text/javascript"></script>
<script src="../../../Scripts/jquery.cookie.js" type="text/javascript"></script>
<script src="../../../Scripts/jquery.treeview.js" type="text/javascript"></script>
<script src="../../../Scripts/jquery.treeview.edit.js" type="text/javascript"></script>
<script src="../../../Scripts/tinybox.js" type="text/javascript"></script>
<script src="../../../../Style/xxk.js" type="text/javascript"></script>
<script src="../../../Scripts/zhezhao.js" type="text/javascript"></script>
    
<style type="text/css">
.Create_Recipe{ margin-top:0;}
.Create_Recipe{ border:1px solid #159aec; border-top:none; width:998px;} 
.soso_lt{ padding:5px 0;}
.soso_lt a{ margin-left:3px;}
.link_add{background-image:url('../../../Images/link_add.png'); width:57px; height:20px; text-align:right; display:block;}
.swxx_table tbody td{padding:5px;}
</style>
<script type="text/javascript">
    //添加食谱库
    function Tr_Add() {
        $("#btn_Save_Edit").hide();
        $("#btn_Save_Add").show();
        $("#div_main input[type='text']").val("");
        divshow("div_main", "div_bg");
    }

    function Tr_Save_Add() {
        var LName = $("#txt_name").val();
        var temp1 = $("#drop_tedian").val(); //人群特点
        var Back = $("#txt_center").val();

        $.ajax({
            type: "Post",
            url: "Caipushezhi.aspx/Add_library",
            data: "{'LName':'" + LName + "','Back':'" + Back + "','temp1':'" + temp1 + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                if (data.d == "OK") {
                    alert("保存成功！");
                    history.go(0);
                }
            }
        });
    }

    //修改食谱库
    function Tr_Edit(cid) {
        $("#btn_Save_Edit").show();
        $("#btn_Save_Add").hide();
        $("#Hidcid").val(cid);
        Caipushezhi.GetlibraryByID(cid, Loadlibrary);
    }

    function Loadlibrary(data) {
        if (data.value == null) {
            return;
        }
        var ds = data.value;
        if (ds != null && ds.Rows[0] != undefined && typeof (ds) == "object") {
            $("#txt_name").val(ds.Rows[0].LName);
            $("#drop_tedian").val(ds.Rows[0].temp1);
            $("#txt_center").val(ds.Rows[0].Back);
        }
        divshow("div_main", "div_bg");
    }

    function Tr_Save_Edit() {
        var CID = $("#Hidcid").val();
        var LName = $("#txt_name").val();
        var temp1 = $("#drop_tedian").val(); //人群特点
        var Back = $("#txt_center").val();

        $.ajax({
            type: "Post",
            url: "Caipushezhi.aspx/Edit_library",
            data: "{'CID':'" + CID + "','LName':'" + LName + "','Back':'" + Back + "','temp1':'" + temp1 + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                if (data.d == "OK") {
                    alert("保存成功！");
                    history.go(0);
                }
            }
        });
    }

    //删除食谱库
    function Tr_Del(cid) {
        if (!confirm("确认删除?")) {
            return;
        }

        $.ajax({
            type: "Post",
            url: "Caipushezhi.aspx/Del_library",
            data: "{'strid':'" + cid + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                if (data.d == "OK") {
                    alert("删除成功！");
                    history.go(0);
                }
            }
        });
    }

</script>
</head>
<body>
<form id="form1" runat="server">
<asp:HiddenField ID="Hidcid" runat="server" />
<div class="Center_Content" id="div2_4">
    <div class="div_0207 left_width400" style="height:auto; width:998px;">
        <table width="100%" style="background:url('../../../Images/div_h1_bg.gif');" cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td><h1><img src="../../../Images/cp_h1_03.gif" />菜谱库</h1></td>
                <td align="right"><a href="javascript:void(0);" onclick="Tr_Add()" class="link_add"> </a></td>
            </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="swxx_table">
            <thead>
                <tr>
                    <td width="6%">序号</td>
                    <td width="25%">菜谱库名称</td>
                    <td width="24%">适用人群</td>
                    <td width="33%">描述</td>
                    <td width="12%" colspan="2" style="border-right:none;">操作</td>
                </tr>
            </thead>
            <tbody id="libery_List">
                <asp:Repeater runat="server" ID="Rep_shipu">
                    <ItemTemplate>
                        <tr id="tr_<%#Eval("id") %>" style="background:#ffffff;" onmouseover="this.style.background='#E3F5FF'" onmouseout="this.style.background='#FFFFFF'">
                            <td class="xh_td"><%#Eval("id") %></td>
                            <td align="center"><%#Eval("LName")%></td>
                            <td align="center">
                                <%#this.Get_Group_tedianName(Eval("temp1").ToString())%>
                            </td>
                            <td><%#Eval("Back").ToString() == "" ? "&nbsp;" : Eval("Back")%></td>
                            <td align="center"><a href="javascript:void(0);"><img src="../../../Images/file.gif" onclick="Tr_Edit('<%#Eval("id") %>')"/></a></td>
                            <td align="center"><a href="javascript:void(0);"><img src="../../../Images/trash.gif" onclick="Tr_Del('<%#Eval("id") %>')"/></a></td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table><br />
    </div>
</div>

<!--弹出层-->
<div id="div_bg" class="bg"></div>
<div id="div_main" class="center_div" style="padding:0px; margin-top:-130px;">
    <div class="div_0207" style="width:478px; margin-top:0px;">
        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color:#E5F1FD;">
            <tr>
                <td><h1 style="background-image:none;"><img src="../../../Images/cp_h1_03.gif" />菜谱库</h1></td>
                <td width="36" align="center"><a href="javascript:void(0);" onclick="divhidel('div_main', 'div_bg')">关闭</a></td>
            </tr>
        </table>
    </div>
    <table border="0" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td height="36" width="70" align="right">名　称：</td>
            <td width="130"><input type="text" id="txt_name" style="width:120px;" class="input_bg" /></td>
            <td width="70" align="right">适用人群：</td>
            <td width="130"><asp:DropDownList runat="server" CssClass="select_input_bg" Width="120" ID="drop_tedian"></asp:DropDownList></td>
        </tr>
        <tr>
            <td height="70" align="right">描　述：</td>
            <td colspan="3"><textarea id="txt_center" class="input_bg" style="width:340px; height:60px;"></textarea></td>
        </tr>
        <tr>
            <td></td>
            <td align="center" height="50">
                <input type="button" id="btn_Save_Edit" onclick="Tr_Save_Edit()" value="提　交" class="input_btn_a" />
                <input type="button" id="btn_Save_Add" onclick="Tr_Save_Add()" value="提　交" class="input_btn_a" />
            </td>
            <td colspan="2">
                <input type="button" id="btn_quxiao" onclick="divhidel('div_main', 'div_bg')" value="取　消" class="input_btn_a" />
            </td>
        </tr>
    </table>
</div>
</form>
</body>
</html>
